package algotithm.acwing.test2816;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/6-17:34
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] num = reader.readLine().split(" ");
        int n = Integer.parseInt(num[0]);
        int m = Integer.parseInt(num[1]);
        int[] arr1 = new int[n];
        int[] arr2 = new int[m];
        String[] s1 = reader.readLine().split(" ");
        String[] s2 = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            arr1[i] = Integer.parseInt(s1[i]);
        }
        for (int i = 0; i < m; i++) {
            arr2[i] = Integer.parseInt(s2[i]);
        }
        reader.close();
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (arr1[i] == arr2[j]) {
                i++;
                j++;
            } else {
                j++;
            }
        }
        if (i == arr1.length) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}
